﻿module Enferno.Public.Web.Components.Models {

    export class DeliveryMethodModel {
        public id: number;
        public cost: number;
        public description: string;
        public imageUrl: string;
        public isForCompanyOnly: boolean;
        public isForPersonOnly: boolean;
        public isSelected: boolean;
        public name: string;
        public partNo: string;
        public price: number;
        public typeName: string;
        public vatRate: number;

        constructor();
        constructor(serverObject: any);
        constructor(serverObject?: any) {
            if (serverObject != null) {
                this.createFromServerObject(serverObject);
            }
        }

        private createFromServerObject(serverObject: any) {
            this.id = serverObject.id;
            this.cost = serverObject.cost;
            this.description = serverObject.description;
            this.imageUrl = serverObject.imageUrl;
            this.isForCompanyOnly = serverObject.isForCompanyOnly;
            this.isForPersonOnly = serverObject.isForPersonOnly;
            this.isSelected = serverObject.isSelected;
            this.name = serverObject.name;
            this.partNo = serverObject.partNo;
            this.price = serverObject.price;
            this.typeName = serverObject.typeName;
            this.vatRate = serverObject.vatRate;
        }

        public serialize(): any {
            var obj: any = {};
            obj.id = this.id;
            obj.cost = this.cost;
            obj.description = this.description;
            obj.imageUrl = this.imageUrl;
            obj.isForCompanyOnly = this.isForCompanyOnly;
            obj.isForPersonOnly = this.isForPersonOnly;
            obj.isSelected = this.isSelected;
            obj.name = this.name;
            obj.partNo = this.partNo;
            obj.price = this.price;
            obj.typeName = this.typeName;
            obj.vatRate = this.vatRate;

            return obj;
        }
    }
} 